<script>
import { mapState, mapMutations, mapGetters } from 'vuex';
export default {
  computed: {
    ...mapState(['count']),
    ...mapGetters(['vipCount'])
  },
  methods: {
    ...mapMutations(['add'])
  },
  mounted () {
    // this.$store.commit('add')
    // 调用方法
    // this.add()

    console.log(this.$store.state.student);
    this.$store.commit('changeName')
  },
}
</script>
<!-- <script setup>
import { useStore } from 'vuex';
const store = useStore()

// console.log(store.state.count);

store.commit('add')
const count = store.state.count

// store.getters.vipCount
</script> -->
<template>
  <div>
    <h1>vuex 使用</h1>

    <!-- <h1>{{ $store.state.count }}</h1> -->
    <h1>{{ count }}</h1>


    <!-- <h1>{{ $store.getters.vipCount }}</h1> -->
    <h1>{{ vipCount }}</h1>


    <h1>{{ $store.state.student }}</h1>
  </div>
</template>
